/**
 * 给定一个数组以及一个01字符串，两种操作
 * 1. L R：将s[L...R]01翻转
 * 2. g：g必然为{0,1}，如果为0，则si为0的那些位置对数组A的元素求异或，否则就是si为1的那些位置异或
 * 使用前缀和即可
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using Real = long double;
using llt = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

#ifndef ONLINE_JUDGE
int const SZ = 101;
#else
int const SZ = 110;
#endif

int N, Q;
string S;
vector<llt> A;
vector<llt> B;
llt ONE, ZERO;

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase; cin >> nofkase;
	while(nofkase--){
        cin >> N;
		A.assign(N, 0);
		B.assign(N + 1, 0);
		for(auto & i : A) cin >> i;
		cin >> S;
        ONE = ZERO = 0;
		for(int i=0;i<N;++i){
			if('0' == S[i]) ZERO ^= A[i];
			else if('1' == S[i]) ONE ^= A[i];
			else assert(0);
			B[i + 1] = A[i] ^ B[i];
		}

		cin >> Q;
		for(int op,q=1;q<=Q;++q){
            cin >> op;
			if(1 == op){
                int a, b; cin >> a >> b;
				ONE ^= B[b] ^ B[a - 1];
				ZERO ^= B[b] ^ B[a - 1];
			}else if(2 == op){
                int g; cin >> g;
                if(0 == g) cout << ZERO << " ";
				else if(1 == g) cout << ONE << " ";
				else assert(0);
			}else{
				assert(0);
			}
		}
		cout << endl;
	}
    return 0;
}